﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Fiuba.Algo3.Titiritero
{
    public class Panel : System.Windows.Forms.Panel, ISuperficieDeDibujo
    {
        public Panel()
        {
            this.Limpiar();
        }

        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
             base.OnPaint(e);
             this.DoubleBuffered = true;
             SolidBrush brocha = new SolidBrush(System.Drawing.Color.Black);
             var g = e.Graphics;
             g.FillRectangle(brocha, 0, 0, this.Width, this.Height);

        }
        public void Actualizar()
        {
         //   Action metodoAInvocar = new Action(this.Refresh);
          //  this.Invoke(metodoAInvocar);
        }

        public void DibujarLinea()
        {
            SolidBrush brocha = new SolidBrush(System.Drawing.Color.Red);
            var g = this.CreateGraphics();
            g.FillRectangle(brocha, 0, 0, this.Width/2, this.Height/2);
        }

        public void Limpiar()
        {
            this.DoubleBuffered = true;
            SolidBrush brocha = new SolidBrush(System.Drawing.Color.Black);
            var g = this.CreateGraphics();
            g.FillRectangle(brocha, 0, 0, this.Width, this.Height);
        }

        public Object Buffer
        {
            get
            {
                return this.CreateGraphics();
            }
        }

        public Panel(int ancho, int alto, ControladorJuego unControlador)
        {
            //this.addMouseListener(new MouseClickController(unControlador));
            //this.addKeyListener(new KeyPressedController(unControlador));
            this.Height = alto;
            this.Width = ancho;
        }

        public Panel(int ancho, int alto)
        {
            this.Width = ancho;
            this.Height = alto;
        }


    }
}
